function [action,stat]=action_selector(stat)

global NA 

ran=rand(1);



if ran < stat.explore
% explore
stat.flag=1;
else
stat.flag=0;
end

state=stat.current_state;

if stat.beta(state,1)>stat.beta(state,2)

   if stat.flag==0
   action=1;
   else
   action=2;
   end

else

   if stat.flag==0
   action=2;
   else
   action=1;
   end

end

%stat.explore=log(stat.iter+1)/(stat.iter+1)*0.5;
stat.explore=stat.explore*0.9999;
